package com.wzdigit.wms.hm.config.ws;
/*
 * @Author:yangwenbiao
 * @Date 2021/5/15 1:12 PM
 * @version 1.0
 */

import com.wzdigit.wms.hm.service.hm.HackingMachineService;
import com.wzdigit.wms.hm.service.hm.PalletizerService;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {

//    @Autowired
//    GdnService gdnService;
//
//    @Autowired
//    AsnService asnService;

    @Autowired
    HackingMachineService hackingMachineService;

    @Autowired
    PalletizerService palletizerService;

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public ServletRegistrationBean cxfServlet() {
        return new ServletRegistrationBean(new CXFServlet(),"/webservice/*");
//        return new ServletRegistrationBean(new CXFServlet(),"/*");
    }

    @Bean
    public Endpoint endpoint() {

        EndpointImpl endpoint = new EndpointImpl(springBus(), hackingMachineService);
//        endpoint.publish("/hackingMachineService/api");
        endpoint.publish("/PalletizerCheckSNService.asmx");
//        endpoint.getInInterceptors().add();
        return endpoint;
    }

    @Bean
    public Endpoint endpoint1() {
        EndpointImpl endpoint1 = new EndpointImpl(springBus(), palletizerService);
        endpoint1.publish("/PalletizerService.asmx");
        return endpoint1;
    }
}
